﻿#region Copyright (c) 2012-10, Olaf Kober <amarok.projects@gmail.com>
//================================================================================
//	Permission is hereby granted, free of charge, to any person obtaining a copy
//	of this software and associated documentation files (the "Software"), to deal
//	in the Software without restriction, including without limitation the rights
//	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//	copies of the Software, and to permit persons to whom the Software is
//	furnished to do so, subject to the following conditions:
//
//	The above copyright notice and this permission notice shall be included in
//	all copies or substantial portions of the Software.
//
//	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//	THE SOFTWARE.
//================================================================================
#endregion

using System;
using System.Globalization;
using Amarok.Resources;


namespace Amarok
{
	/// <summary>
	/// This type represents a base class for Identity implementations.
	/// </summary>
	[Serializable]
	public abstract class Identity
	{
		#region ++ Public Interface ++

		/// <summary>
		/// Returns the hash code for the current Identity instance. 
		/// </summary>
		/// 
		/// <returns>
		/// A 32-bit signed integer hash code.</returns>
		public override Int32 GetHashCode()
		{
			throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture,
				ExceptionResources.IdentityBaseMethodShouldNotBeCalled,
				this.GetType().AssemblyQualifiedName));
		}

		/// <summary>
		/// Determines whether the specified Identity instance is equal to the current instance.
		/// </summary>
		/// 
		/// <param name="other">
		/// The Identity instance to compare with the current instance.</param>
		/// 
		/// <returns>
		/// True, if the specified Identity instance is equal to the current instance; otherwise, False.</returns>
		public override Boolean Equals(Object other)
		{
			throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture,
				ExceptionResources.IdentityBaseMethodShouldNotBeCalled,
				this.GetType().AssemblyQualifiedName));
		}


		/// <summary>
		/// Determines whether the specified Identity instances are equal.
		/// </summary>
		/// 
		/// <param name="a">
		/// The first Identity instance to compare.</param>
		/// <param name="b">
		/// The second Identity instance to compare.</param>
		/// <returns>
		/// True, if the specified Identity instances are equal; otherwise, False.</returns>
		public static Boolean operator ==(Identity a, Identity b)
		{
			return (Object)a == null ? (Object)b == null : a.Equals((Object)b);
		}

		/// <summary>
		/// Determines whether the specified Identity instances are unequal.
		/// </summary>
		/// 
		/// <param name="a">
		/// The first Identity instance to compare.</param>
		/// <param name="b">
		/// The second Identity instance to compare.</param>
		/// <returns>
		/// True, if the specified Identity instances are unequal; otherwise, False.</returns>
		public static Boolean operator !=(Identity a, Identity b)
		{
			return (Object)a == null ? (Object)b != null : !a.Equals((Object)b);
		}

		#endregion

		#region ## Protected Interface ##

		/// <summary>
		/// Initializes a new instance.
		/// </summary>
		protected Identity()
		{
		}

		#endregion

	}
}
